#ifndef __PID_H
#define __PID_H

#ifdef __cplusplus
extern "C"
{
#endif

#include <stdint.h>

    typedef struct
    {
        float Kp;
        float Ki;
        float Kd;

        float output_max;
        float output_min;
        
        float error_total_threshold;
    } pid_config_t;

    typedef struct
    {
        pid_config_t config;
        float error;
        float error_prev;
        float error_total;
    } pid_t;

    void PID_Init(pid_t *pid, const pid_config_t *config);
    void PID_Clear(pid_t *pid);
    float PID_Update(pid_t *pid);

#ifdef __cplusplus
}
#endif

#endif /* __PID_H */